//
//  ImageOrientationView.m
//  LyhToolsTest
//
//  Created by 李彦宏 on 2020/11/18.
//  Copyright © 2020 LYH.com. All rights reserved.
//

#import "ImageOrientationView.h"

@implementation ImageOrientationView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self = [[NSBundle mainBundle]loadNibNamed:@"ImageOrientationView" owner:self options:nil][0];
    }
    return self;
}
- (IBAction)shun90:(id)sender {
    
    [self setImageOrient:UIImageOrientationRight];
}

- (IBAction)shun180:(id)sender {
   [self setImageOrient:UIImageOrientationDown];
}

- (IBAction)Ni90:(id)sender {
   [self setImageOrient:UIImageOrientationLeft];
}

- (IBAction)Ni180c:(id)sender {
    
    [self setImageOrient:UIImageOrientationDownMirrored];
}

- (IBAction)restoreAction:(id)sender {
    UIImage *backImage = [UIImage imageNamed:@"img1"];
    self.imageV.image = backImage;
}


-(void)setImageOrient:(UIImageOrientation)Orientation
{
   UIImage *backImage = [UIImage imageNamed:@"img1"];

    //改变该图片的方向
    backImage = [UIImage imageWithCGImage:backImage.CGImage
                                    scale:backImage.scale
                              orientation:Orientation];
    
    self.imageV.image = backImage;
}

@end
